<?php
	class model_answer extends CI_Model{
		protected $_table = "tbl_answers";
		protected $_question = "tbl_questions";
		public function __construct(){
			parent::__construct();
		}
		public function listall($off,$start){
			$this->db->order_by("aid","DESC");
			$this->db->join('tbl_user','tbl_user.user_id = tbl_answers.userid');
			return $this->db->get($this->_table)->result_array();
		}
		public function countall(){
			$this->db->join('tbl_user','tbl_user.user_id = tbl_answers.userid');
			return $this->db->count_all_results($this->_table);
		}
		public function add($data){
			$this->db->insert($this->_table,$data);
		}
		public function getdata($id){
			$this->db->where("aid",$id);
			return $this->db->get($this->_table)->row_array();
		}
		public function update($id,$data){
			$this->db->where("aid",$id);
			return $this->db->update($this->_table,$data);
		}
		public function del($id){
			$this->db->where("aid",$id);
			return $this->db->delete($this->_table);
		}
	}